package com.example.administrator.about_huanxin.fragment.tongxun;

import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.example.administrator.about_huanxin.R;
import com.example.administrator.about_huanxin.adapter.HaoYouAdapter;
import com.example.administrator.about_huanxin.fragment.BaseFragment;
import com.example.administrator.about_huanxin.model.UserEntity;
import com.example.administrator.about_huanxin.presenter.fragment.HaoYouPresener;
import com.example.administrator.about_huanxin.presenter.fragment.HaoYouPresnerImp;
import com.example.administrator.about_huanxin.view.fragment.HaoYouFragmentView;

import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by Administrator on 2017/3/23 0023.
 */

public class HaoYouFragment extends BaseFragment implements HaoYouFragmentView {


    @Bind(R.id.haoyou_recycle)
    RecyclerView haoyouRecycle;

    private HaoYouPresener haoYouPresener;
    private HaoYouAdapter adapter;

    @Override
    public void setEmptyView(TextView tv, boolean isVisible) {
        tv.setVisibility(View.GONE);
    }

    @Override
    public void setTitleText(TextView tv) {
        tv.setText("好友");
    }

    @Override
    public void setTitleButton(Button btn) {
        btn.setVisibility(View.GONE);
    }

    @Override
    protected void setVisibleTitle(LinearLayout ll) {
        super.setVisibleTitle(ll);
        ll.setVisibility(View.GONE);
    }

    @Override
    public View setContainer(LayoutInflater inflater, FrameLayout fram) {
        View view = inflater.inflate(R.layout.fragment_haoyou, fram, true);
        ButterKnife.bind(this, view);
        return view;
    }

    @Override
    public void initContent(View content) {
        haoYouPresener = new HaoYouPresnerImp(this);
        haoYouPresener.getFrienList();

        haoyouRecycle.setLayoutManager(new LinearLayoutManager(getActivity()));
        adapter = new HaoYouAdapter(getActivity(),null);
        haoyouRecycle.setAdapter(adapter);
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        ButterKnife.unbind(this);
    }

    @Override
    public void getFriendReturnViewList(List<UserEntity> users) {
        if(users != null){
            adapter.setRefresh(users);
        }
    }
}
